package com.xm.service.background;

import com.xm.dao.background.CommodityWarehouseDao;
import com.xm.exception.SqlErrorException;

import java.sql.SQLException;

/**
 * 商品库存
 * @author 康文程
 * @date 2024-1-12
 */
public class CommodityWarehouseService {
    private final CommodityWarehouseDao dao = new CommodityWarehouseDao();
    /**
     * 更新商品库存
     *
     * @param commodityWarehouseId 商品货仓编号
     * @param newInventory         更新后的库存数量
     * @return 更新是否成功
     * @throws SQLException SQL执行异常
     */
    public boolean updateInventory(int commodityWarehouseId, int newInventory) throws SQLException {
        return dao.updateInventory(commodityWarehouseId, newInventory);
    }
    /**
     * 查询库存商品数量
     * @return 订单数量
     * @throws SqlErrorException SQL执行异常
     */
    public int getCommodityWarehouseNine() throws SqlErrorException {
        return dao.getCommodityWarehouseNine();
    }
    /**
     * 查询库存商品数量小于等于50的记录，并插入到事项表中
     * @throws SqlErrorException SQL执行异常
     */
    public void insertMattersFromCommodityWarehouse() throws SqlErrorException {
        dao.insertMattersFromCommodityWarehouse();
    }
    /**
     * 新增商品库存
     *
     * @param warehouseId   仓库Id
     * @param commodityId   商品Id
     * @return 新增是否成功
     * @throws SqlErrorException SQL执行异常
     */
    public boolean addCommodityWarehouse(Integer warehouseId, Integer commodityId) throws SqlErrorException {
        return dao.addCommodityWarehouse(warehouseId, commodityId);
    }
}
